package properties;

import java.util.Properties;
import java.util.Set;

/*
Properties集合
本质上是map集合，键和值都是String
 */
public class Demo1 {
    public static void main(String[] args) {
        Properties prop = new Properties();
        prop.setProperty("username","admin");
        prop.setProperty("password","admin");

        //遍历,获取key的集合
        Set<String> keySet = prop.stringPropertyNames();
        for (String key : keySet) {
            System.out.println(key + "=" + prop.getProperty(key));
        }
    }

    //set get方法
    private static void method1() {
        Properties prop = new Properties();
        prop.setProperty("username","admin");
        prop.setProperty("password","admin");
        String s1 = prop.getProperty("username");
        String s2 = prop.getProperty("password");
        System.out.println(s1);
        System.out.println(s2);
    }
}
